<template>
	<view class="p20">
		<view class="flex flex-col row-center mt84 px40" v-if="!list.length">
			<image src="/static/img/my/addPatient.png" class="h360 w360" mode=""></image>
			<view class="fs30 color-B7B5B5 mt36 ">您还未添加就诊人~</view>
		</view>
		<view v-for="(item,index) in list" :key="index" @click="set(item)" class="bg-fff p20 mb20 radius20">
			<view class=" border-b pb22">
				<view class="flex row-between">
					<view class="flex">
						<view class=""> {{item.name}}</view>
						<image src="/static/img/my/girl.png" v-if="item.sex==2" class="h36 w36 ml16" mode="">
						</image>
						<image src="/static/img/my/boy.png" v-if="item.sex==1" class="h36 w36 ml16" mode=""></image>
					</view>
					<view class="color-666">{{item.relation}}</view>
				</view>
				<view class="flex row-between">
					<view class="color-999 fs26 mt14"> 年龄：{{item.age}}</view>
					<view class="color-999 fs26 mt14">{{item.card_no}}</view>
				</view>
			</view>
			<view class="fs28 color-666 flex fs24 mt30">
				<view class="flex" @click.stop="$jump('/pages/my/addPatient/addPatient',{id:item.id})">
					<image src="/static/img/my/edit.png" class="h32 w32" mode=""></image>
					<view class="color-fs ml14">修改</view>
				</view>
				<view class="flex ml60" @click.stop="del(item)">
					<image src="/static/img/my/delete.png" class="h32 w32 " mode=""></image>
					<view class="color-zs ml14">删除</view>
				</view>
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf bottom0 left0 w-max p20">
			<view class="bg-zs color-fff h84 radius12 flex row-center"
				@click="$jump('/pages/my/addPatient/addPatient')">
				+ 添加就诊人
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: '',
				page:1
			};
		},
		onShow() {
			this.getList()
		},
		onReachBottom(e) {
			this.getList('down')
		},
		methods: {
			getList(e) {
				e == 'down' ? this.page++ : this.page = 1
				this.$request('/member/patient/patientList', {
					...this.$params,
					page:this.page,
				}).then(res => {
					let list = res.data.data
					e == 'down' ? this.list.push(...list) : this.list = list
				})
			},
			set(item) {
				if (!this.$params.set) return
				uni.$emit(this.$params.set, item)
				this.$navBack()
			},
			async del(item) {
				await this.$showModal('删除')
				this.$request('/member/patient/patientDel', {
					id: item.id
				}).then(res => {
					this.$msg(res.msg)
					this.getList()
				})
			}
		}
	}
</script>

<style lang="scss">
	// page {
	// 	background-color: #FFFFFF;
	// }
</style>